﻿using FirstFloor.ModernUI.Presentation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Export.Ui.ViewModel.Order
{
    public class NewOrderDetailViewModel
    {
        private OrderDetail _newOrderDetail;
        private OrderDetailViewModel _orderDetailVM;

        public NewOrderDetailViewModel(OrderDetailViewModel orderDetailVM)
        {
            _orderDetailVM = orderDetailVM;
            InitailCommand();
            _newOrderDetail = new OrderDetail();
            _newOrderDetail.OrderNo = orderDetailVM._orderNo;
        }

        public string OrderNo
        {
            get
            {
                return _newOrderDetail.OrderNo;
            }

            set
            {
                _newOrderDetail.OrderNo = value;
            }
        }

        public string MaterialNo {
            get
            {
                return _newOrderDetail.MaterialNo;
            }

            set
            {
                _newOrderDetail.MaterialNo = value;
            }
        }

        public string ProductName
        {
            get
            {
                return _newOrderDetail.ItemId;
            }

            set
            {
                _newOrderDetail.ItemId = value;
            }
        }

        public int Qty {
            get
            {
                return _newOrderDetail.Qty;
            }

            set
            {
                _newOrderDetail.Qty = value;
            }
        
        }

        public OrderDetail NewOrderDetail
        {
            get
            {
                return _newOrderDetail;
            }
        }

        public bool IsAdd { get; set; }

        public RelayCommand AddCommand { get; set; }
        public RelayCommand CloseCommand { get; set; }

        private void InitailCommand()
        {
            AddCommand = new RelayCommand(Add);
            CloseCommand = new RelayCommand(close);
        }

        private void Add(object parameter)
        {
            IsAdd = true;
            _orderDetailVM.NewOrderDetailDialog.Close();
        }

        private void close(object parameter)
        {
            IsAdd = false;
            _orderDetailVM.NewOrderDetailDialog.Close();
        }
    }
}
